package com.fangcun.controller.admin.old;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fangcun.bean.sys.PageBean;
import com.fangcun.bean.sys.ResponseMsg;
import com.fangcun.common.canstant.ErrCode;
import com.fangcun.common.exception.ProException;
import com.fangcun.common.util.PublicMethod;
import com.fangcun.common.util.apiversion.ApiVersion;
import com.fangcun.common.util.base.BaseAdminController;
import com.fangcun.entity.UserWithdrawCashList;
import com.fangcun.service.admin.UserWithdrawService;

@RestController
@RequestMapping("/admin/{version}/auth/user/withdraw")
public class UserWithdrawListController extends BaseAdminController {
	
	private static Logger LOG = LoggerFactory.getLogger(UserWithdrawListController.class);
	
	@Autowired
	private UserWithdrawService userWithdrawService;
	
	//提现 后台 列表 
	@ApiVersion(1.0)
	@RequestMapping("list")
	private ResponseMsg list(@RequestBody PageBean<UserWithdrawCashList> request) {
		ResponseMsg msg = ResponseMsg.returnBeanBuild();
		try {
			msg.setData(userWithdrawService.list(request));
		} catch (ProException e) {
			LOG.error("-后台-提现列表->{},{},{}", msg.getSessionId(), e.getErrorCode(), e.getErrorMsg());
			msg.setReturnCode(e.getErrorCode()).setReturnMsg(e.getErrorMsg());
		} catch (Exception e) {
			LOG.error("-后台-提现列表--->{},{}", msg.getSessionId(), PublicMethod.printErrorTrace(e));
			msg.setReturnCode(ErrCode.ERR.getReturnCode()).setReturnMsg(ErrCode.ERR.getReturnMsg());
		}
		return msg;
	}
	//详情
	@ApiVersion(1.0)
	@RequestMapping("details")
	private ResponseMsg details(Long id) {
		ResponseMsg msg = ResponseMsg.returnBeanBuild();
		try {
			msg.setData(userWithdrawService.details(id));
		} catch (ProException e) {
			LOG.error("-后台-提现详情出错->{},{},{}", msg.getSessionId(), e.getErrorCode(), e.getErrorMsg());
			msg.setReturnCode(e.getErrorCode()).setReturnMsg(e.getErrorMsg());
		} catch (Exception e) {
			LOG.error("-后台-提现详情异常--->{},{}", msg.getSessionId(), PublicMethod.printErrorTrace(e));
			msg.setReturnCode(ErrCode.ERR.getReturnCode()).setReturnMsg(ErrCode.ERR.getReturnMsg());
		}
		return msg;
	}
	//修改
	@ApiVersion(1.0)
	@RequestMapping("update")
	private ResponseMsg update(@RequestBody UserWithdrawCashList request) {
		ResponseMsg msg = ResponseMsg.returnBeanBuild();
		try {
			userWithdrawService.update(request,getAdminUserId());
		} catch (ProException e) {
			LOG.error("-后台-提现修改功能出错->{},{},{}", msg.getSessionId(), e.getErrorCode(), e.getErrorMsg());
			msg.setReturnCode(e.getErrorCode()).setReturnMsg(e.getErrorMsg());
		} catch (Exception e) {
			LOG.error("-后台-提现修改功能异常--->{},{}", msg.getSessionId(), PublicMethod.printErrorTrace(e));
			msg.setReturnCode(ErrCode.ERR.getReturnCode()).setReturnMsg(ErrCode.ERR.getReturnMsg());
		}
		return msg;
	}
}
